load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//pkg/testutils:buildutil/buildutil.bzl", "disallowed_imports_test")

go_library(
    name = "inverted",
    srcs = ["expression.go"],
    embed = [":inverted_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/inverted",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/keysbase",
        "//pkg/util/treeprinter",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_redact//:redact",
    ],
)

go_test(
    name = "inverted_test",
    size = "small",
    srcs = ["expression_test.go"],
    data = glob(["testdata/**"]),
    embed = [":inverted"],
    deps = [
        "//pkg/testutils/datapathutils",
        "//pkg/util/encoding",
        "//pkg/util/leaktest",
        "//pkg/util/treeprinter",
        "@com_github_cockroachdb_datadriven//:datadriven",
        "@com_github_gogo_protobuf//proto",
        "@com_github_stretchr_testify//require",
    ],
)

proto_library(
    name = "inverted_proto",
    srcs = ["span_expression.proto"],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = ["@com_github_gogo_protobuf//gogoproto:gogo_proto"],
)

go_proto_library(
    name = "inverted_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/inverted",
    proto = ":inverted_proto",
    visibility = ["//visibility:public"],
    deps = ["@com_github_gogo_protobuf//gogoproto"],
)

disallowed_imports_test(
    "inverted",
    ["//pkg/roachpb"],
)
